<?php 

$arr =array(1,2,3,4,5,6,7,8,9,10);
$arrNew = [];
foreach ($arr as $key => $value) {
	if($key%2==0)
	{
		 array_push($arrNew, $value);
	}
}

echo array_sum($arrNew)/count($arrNew);


echo "<hr>";



function test($num)
{
	$str = '';
	for ($i=0; $i <strlen($num) ; $i++) { 
		 $str.=($num[$i]+5)%10;
	}

	return strrev($str);
}

echo test('9876');

echo "<hr>";


function text($str)
{
	$arr = array(
			array('zhansan','lisi','wangwu'),
			array('9','8','7'),
			array('nan','nv','nan')
		);

	foreach ($arr as $key => $value) {
		foreach ($value as $k => $v) {
			if($v == $str)
			{
				$arr[$key][$k] = "<font color='red'>".$v."</font>";
			}
		}
	}
	return $arr;
}

print_r(text('zhansan'));


echo "<hr>";


$str = 'hello word!';
$strs = str_replace(' ', '@', $str);
echo $strs;


echo "<hr>";

function save($num)
{
	return str_repeat('*', $num);
}

echo save(3);


echo "<hr>";

$str = "861745122@qq.com";

$strs = strstr($str,'.');

echo $strs;

echo "<hr>";

$arr = array('唱歌','跳舞','捉迷藏','跑步');
$arrs = implode(',', $arr);
echo $arrs;

echo "<hr>";

$str = "insert into user(name,age)values(‘张三’,20),";
$strs = substr($str,0,-1);
echo $strs;

echo "<hr>";

function aaa()
{
	$str = "hello-shang-hai";

	$arr = explode('-',$str);
	foreach ($arr as $key => $value) {
		if($key != 0)
		{
			$arr[$key] = ucfirst($value);
		}
	}

	return implode('', $arr);
}
print_r(aaa());

?>